//
//  MyfenleiCollectionViewController.m
//  IOSFM
//
//  Created by lanou3g on 15/12/16.
//  Copyright © 2015年 朱梦扬. All rights reserved.
//

#import "MyfenleiCollectionViewController.h"
#import "CollectionViewCell.h"
#import "XYMCollectionViewController.h"
#import "RootTableViewController.h"
@interface MyfenleiCollectionViewController ()<UICollectionViewDelegateFlowLayout>

@end

@implementation MyfenleiCollectionViewController

static NSString * const reuseIdentifier = @"MYCell";


- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor orangeColor];
// [self.collectionView registerClass:[CollectionViewCell class] forCellWithReuseIdentifier:reuseIdentifier];
    
    UINib *nib = [UINib nibWithNibName:@"CollectionViewCell" bundle:[NSBundle mainBundle]];
    [self.collectionView registerNib:nib forCellWithReuseIdentifier:reuseIdentifier];
    
    self.collectionView.backgroundColor = [UIColor whiteColor];

    
    
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

#pragma mark <UICollectionViewDataSource>

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
//#warning Incomplete implementation, return the number of sections
    return 3;
}


- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
//#warning Incomplete implementation, return the number of items
    if (section == 0) {
        return 16;
    } else if (section == 1 || section == 2) {
        return 8;
    }
    return 0;
}

// 点击cell到下一界面
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0 && (indexPath.item == 0 || indexPath.item == 2 || indexPath.item == 3 )) {
        RootTableViewController *root = [[RootTableViewController alloc] init];
        [self.navigationController pushViewController:root animated:YES];
        
    }else{
    
        UICollectionViewFlowLayout *MyflowLayout = [[UICollectionViewFlowLayout alloc] init];
        MyflowLayout.itemSize = CGSizeMake(100,100);
        MyflowLayout.minimumInteritemSpacing = 0;
        MyflowLayout.minimumLineSpacing = 10;
        MyflowLayout.sectionInset = UIEdgeInsetsMake(30, 30, 20, 30);
        
        XYMCollectionViewController *DJCell = [[XYMCollectionViewController alloc] initWithCollectionViewLayout:MyflowLayout];
        [self.navigationController pushViewController:DJCell animated:YES];
    }
    
}




- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
    
  
    
    return cell;
}




#pragma mark <UICollectionViewDelegate>

/*
// Uncomment this method to specify if the specified item should be highlighted during tracking
- (BOOL)collectionView:(UICollectionView *)collectionView shouldHighlightItemAtIndexPath:(NSIndexPath *)indexPath {
	return YES;
}
*/

/*
// Uncomment this method to specify if the specified item should be selected
- (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    return YES;
}
*/

/*
// Uncomment these methods to specify if an action menu should be displayed for the specified item, and react to actions performed on the item
- (BOOL)collectionView:(UICollectionView *)collectionView shouldShowMenuForItemAtIndexPath:(NSIndexPath *)indexPath {
	return NO;
}

- (BOOL)collectionView:(UICollectionView *)collectionView canPerformAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender {
	return NO;
}

- (void)collectionView:(UICollectionView *)collectionView performAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender {
	
}
*/

@end
